﻿using System;
using System.Windows;
using System.Windows.Markup;
using System.Windows.Data;
using nRoute.Components;
using System.ComponentModel;

namespace nRoute.Behaviors
{
    [ContentProperty("Parameters")]
    public abstract class NavigateActionBase
        : NavigationHandlerActionBase
    {

#region Constants and Variables

        public static readonly DependencyProperty UrlProperty = 
            DependencyProperty.Register("Url", typeof(string), typeof(NavigateActionBase), 
            new PropertyMetadata(null));

        //public static readonly DependencyProperty UrlFormatProperty =
        //    DependencyProperty.Register("UrlFormat", typeof(string), typeof(NavigateActionBase),
        //    new PropertyMetadata(null));

        public static readonly DependencyProperty ParametersProperty =
            DependencyProperty.Register("Parameters", typeof(ParametersCollection), typeof(NavigateActionBase),
            new PropertyMetadata(null));

        public static readonly DependencyProperty SiteAreaProperty =
            DependencyProperty.Register("SiteArea", typeof(string), typeof(NavigateActionBase),
            new PropertyMetadata(null));

#endregion

#region Properties

        [Category("Common Properties")]
#if SILVERLIGHT
        [TypeConverter(typeof(nRoute.Components.TypeConverters.ConvertFromStringConverter))]
#endif
        public string Url
        {
            get { return Convert.ToString(GetValue(UrlProperty)); }
            set { SetValue(UrlProperty, value); }
        }

//        [Category("Common Properties")]
//#if SILVERLIGHT
//        [TypeConverter(typeof(nRoute.Components.TypeConverters.ConvertFromStringConverter))]
//#endif
//        public string UrlFormat
//        {
//            get { return Convert.ToString(GetValue(UrlFormatProperty)); }
//            set { SetValue(UrlFormatProperty, value); }
//        }

        [Category("Common Properties")]
        public ParametersCollection Parameters
        {
            get { return (ParametersCollection)GetValue(ParametersProperty); }
            set { SetValue(ParametersProperty, value); }
        }

        [Category("Common Properties")]
        public string SiteArea
        {
            get { return Convert.ToString(GetValue(SiteAreaProperty)); }
            set { SetValue(SiteAreaProperty, value); }
        }

#if SILVERLIGHT

        [Category("Common Properties")]
        public Binding UrlBinding
        {
            get { return GetBinding(UrlProperty); }
            set { SetBinding<string>(UrlProperty, value); }
        }

        //[Category("Common Properties")]
        //public Binding UrlFormatBinding
        //{
        //    get { return GetBinding(UrlFormatProperty); }
        //    set { SetBinding<string>(UrlFormatProperty, value); }
        //}

        [Category("Common Properties")]
        public Binding ParametersBinding
        {
            get { return GetBinding(ParametersProperty); }
            set { SetBinding<ParametersCollection>(ParametersProperty, value); }
        }

        [Category("Common Properties")]
        public Binding SiteAreaBinding
        {
            get { return GetBinding(SiteAreaProperty); }
            set { SetBinding<string>(SiteAreaProperty, value); }
        }

#endif

#endregion

    }
}
